Skip to content

fix(import): tolerate common file variations and say where a file breaks (#19) - #67

Merged
ndreno merged 2 commits into
mainfrom
fix/import-error-detail
Nov 3, 2026
Merged

ndreno merged 2 commits into
mainfrom
fix/import-error-detail

Conversation

@ndreno

@ndreno ndreno commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Refs #19. Doesn't close it: we still have no sample files from the reporter, so this covers what was reproducible without them.

Why

Probing the BeerXML parser showed one odd value failed the whole import with an unlocated serde message: a decimal comma (5,5), a lowercase enum (boil), a common synonym (Whirlpool, Malt), or a hop without <ALPHA>. BeerJSON imports reported Ajv's first error, often a combinator or a property-less "must NOT have additional properties".

BeerXML (werb-beerxml: app import via WASM, and the CLI)

  • Numbers read a decimal comma; with a point present, commas are thousands separators. Failures say not a number: "<raw>".
  • Enums go through LenientEnum: case, spacing and punctuation ignored, plus synonyms (Whirlpool / Hop stand / Flameout → Aroma, Malt → Grain, Whole / Cones → Leaf). Unknown values read as absent and the converter applies its default.
  • Missing hop ALPHA / AMOUNT, fermentable or misc AMOUNT read as 0, like an empty element already did.
  • serde_path_to_error locates failures: Error::Invalid { location } with a 1-based XPath, e.g. /RECIPES/RECIPE[1]/HOPS/HOP[2]/AMOUNT: not a number: "lots". JolieBulle JSON errors carry their field path.

BeerJSON (@werb/validate: file import and GitHub Pull)

  • stripNulls: null optional properties mean absent.
  • describeErrors: the deepest, most telling error, naming the missing or unknown property, or the value and the allowed ones.

Tests

  • Rust: lenient numbers / enums / missing alpha, located errors, JolieBulle path.
  • @werb/validate: stripNulls, describeErrors (enum, required, type).
  • Desktop: WASM import of a loose file and a broken one; BeerJSON with nulls and with a missing property.
  • e2e through the file picker: loose BeerXML imports, broken BeerXML shows the XPath, broken BeerJSON names the property. Full suite 35/35 locally, Rust workspace green, lint clean.

…aks (#19)

#19 reported import errors on files their author considered standard, with
no sample files. Probing the BeerXML parser showed a single odd value failed
the whole import with an unlocated serde message: a decimal comma ("5,5"),
lowercase or upper-case enum values ("boil"), common synonyms ("Whirlpool",
"Malt"), or a hop without <ALPHA>. BeerJSON imports only reported Ajv's
first error, often a combinator ("must match a schema in anyOf") or a
property-less "must NOT have additional properties".

BeerXML (werb-beerxml, so also the CLI and the WASM import):
- Numbers read a decimal comma; with a point present, commas are thousands
  separators. Failures say `not a number: "<raw>"`.
- Enums go through LenientEnum: case, spacing and punctuation ignored, plus
  synonyms (Whirlpool / Hop stand / Flameout -> Aroma, Malt -> Grain,
  Whole / Cones -> Leaf, LME -> Extract...). Unknown values read as absent
  and the converter applies its default.
- A missing hop ALPHA / AMOUNT, fermentable or misc AMOUNT reads as 0, like
  an empty element already did.
- serde_path_to_error locates failures: Error::Invalid { location } with a
  1-based XPath such as /RECIPES/RECIPE[1]/HOPS/HOP[2]/AMOUNT. JolieBulle
  JSON errors carry their field path too.

BeerJSON (@werb/validate, used by file import and GitHub Pull):
- stripNulls: null optional properties mean absent.
- describeErrors: the deepest, most telling error, naming the missing or
  unknown property, or the value and the allowed ones.

Tests: Rust (lenient values, located errors), validator unit tests, WASM
import tests, BeerJSON import tests, e2e imports through the file picker.
# Conflicts:
#	CHANGELOG.md
#	apps/desktop/test/e2e/smoke.spec.ts
@ndreno
ndreno merged commit c84f773 into main Nov 3, 2026
1 check passed
@ndreno
ndreno deleted the fix/import-error-detail branch November 3, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant